{if $errors}
	$.growl.settings.noticeElement($('.growl-error-container'));
	{foreach from="`$errors`" item="error"}
		{if $error == 'USER_LEN'}
			$.growl('ERROR', 'Username must be 5 or more characters.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'USER_UNIQUE'}
			$.growl('ERROR', 'Username must be unique.  This username is already used.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'EMAIL'}
			$.growl('ERROR', 'Email must be valid.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'FIRST_NAME'}
			$.growl('ERROR', 'First name must be provided.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'LAST_NAME'}
			$.growl('ERROR', 'Last name must be provided.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'EMAIL_UNIQUE'}
			$.growl('ERROR', 'Email must be unique.  This email is already used.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'PASS_MATCH'}
			$.growl('ERROR', 'Password confirmation must match.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if $error == 'PASS_REGEX'}
			$.growl('ERROR', '{$env.password.error|escape:"html":"UTF-8"}.');
			$.growl.settings.displayTimeout+=2000;
		{/if}
		{if strpos($error, 'CUSTOM:') === 0}
			$.growl('ERROR', '{$error|substr:7}');
			$.growl.settings.displayTimeout+=2000;
		{/if}
	
	{/foreach}
{/if}

{if $success}
	{if $user_id}
		window.location = '/admin/global/users/edit/{$user_id}';
	{else}
		$.growl.settings.noticeElement($('.growl-message-container'));
		$.growl('UPDATED', 'The user has been updated.');
	{/if}
{/if}

